package com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler;

import com.iwhalecloud.bss.kite.common.constant.KeyConsts;
import com.iwhalecloud.bss.kite.cucc.service.attr.handler.CircuitRentalRangeAttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.annotation.AttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.impl.AbstractAttrLinkageHandler;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import org.springframework.stereotype.Service;

/**
 * @author LIFF
 * @version 2022/3/04 11:52
 * Description: 电路租用范围
 */
@Service
@AttrHandler(CircuitRentalRangeAttrHandler.class)
public class CircuitRentalRangeAttrLinkHandler extends AbstractAttrLinkageHandler<AttrData> {
    @Override
    public void handle(KiteAttr kiteAttr, KiteInst kiteInst, AttrData attrData) {
        KiteAttr attr1 = kiteInst.getAttr("2_0000208");
        KiteAttr attr2 = kiteInst.getAttr("2_0000211");
        KiteAttr attr3 = kiteInst.getAttr("2_0000212");
        if((!kiteAttr.getValue().equals(kiteAttr.getPreValue()) && !kiteAttr.getValue().equals(kiteAttr.getDefaultValue()))
            || ("100004165".equals(kiteAttr.getPreValue()))){
            attr1.setValue(null);
            attr1.setValueDesc(null);
        }
        // 纯境外电路
        if("100004165".equals(kiteAttr.getValue())){
            attr2.setIsNull(KeyConsts.IFTRUE_T);
            attr2.setValue(null);
            attr2.setValueDesc(null);
            attr2.setIsEdit(KeyConsts.IFTRUE_F);
            attr3.setIsNull(KeyConsts.IFTRUE_F);
        }else{
            attr3.setIsNull(KeyConsts.IFTRUE_T);
        }
    }

    @Override
    public void handleStyle(KiteAttr kiteAttr, KiteInst kiteInst, AttrData attrData) {

    }
}
